<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">
		<title>dept_mag.jsp</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<link rel="stylesheet" type="text/css" href="./css/style.css">
		<SCRIPT type="text/javascript">
			function checkSelect()
			{
				var id="";
				var oRadio=document.getElementsByName("check");
				for(var i=0;i<oRadio.length;i++){
				  if(oRadio[i].checked){
				  //alert(oRadio[i].value);
				  	id=oRadio[i].value;
				  	break;
				  }
				}
				return id;
			}
			
			function formsub(){
				if(checkSelect()!=""){
					var id=	checkSelect();
					var f=document.getElementById("myform");
					f.action="./emp/empDelAction?check="+id;
					if (confirm("确定删除")) {
						f.submit();
					}else{
						
					}
				}else{
					alert("您未选中");
				}
			}
		</SCRIPT>
		
		
		
	</head>
	
	
	
	
	<body>
		<div id="blue_button">
			<div id="blue_button_word">&nbsp;员工列表</div>
		</div>
		<div id="right_background">
			&nbsp;
			<br>
			<br>

			<form  method="post" id="myform">
				<table cellspacing="1" class="tab_dept">

					<tr class="tab_header">
						<td valign="middle" align="center">
							员工名称
						</td>
						<td valign="middle" align="center">
							联系电话
						</td>
						<td valign="middle" align="center">
							所属部门
						</td>
						<td>
							性别
						</td>
						<td>
							删除选择
						</td>
					</tr>
					<c:forEach items="${emplist}" var="emp">
						<tr class="row2" onMouseOver="this.className='row1'"
							onMouseOut="this.className='row2'">
							<td valign="middle" align="center">
								<a href="./emp/empDetailAction?id=${emp.EId}">${emp.EName }</a>
							</td>
							<td valign="middle" align="center">
								${emp.EPhone}
							</td>
							<td valign="middle" align="center">
								${emp.EDeptno}
							</td>

							<td valign="middle" align="center">
								<c:choose>

									<c:when test="${emp.ESex == 'M'}">
            							  男
      								</c:when>
									<c:otherwise>
              							女
       								</c:otherwise>
								</c:choose>
								
								<%--<c:if test='%emp.ESex == M'>
							                                   女
						        </c:if>
								<c:else>
								                         男
								</c:else>
							--%></td>

							<td valign="middle" align="center">
								<input type="checkbox" id="check" name="check"
									value="${emp.EId}" />
							</td>
						</tr>
					</c:forEach>
				</table>
				<div>
					${msg }
				</div>
				<input type="button" class="add" value="新 增"
					style="margin-top: 20px; margin-left: 700px;"
					onClick="location.href='./emp/empAddShowAction'" />
				&nbsp; &nbsp;
				<input type="button" class="del" value="删  除" onclick="formsub()"/>
			</form>
			
			<p class="paging">
				<s:if test="%{currentPage == 1}">
				&lt;&lt; 首页 &lt; 上一页
			</s:if>
				<s:else>
					<a href="./emp/empAction?page=1"> &lt;&lt;首页</a>
					<a href="./emp/empAction?page=${currentPage-1}">&lt; 上一页 </a>
				</s:else>
	
				<strong>第${currentPage}页/共${totalPages}页</strong>
				<s:if test="%{currentPage == totalPages}">
				下一页 &gt;
				末页 &gt;&gt;
			</s:if>
				<s:else>
					<a href="./emp/empAction?page=${currentPage+1}"> 下一页 &gt;</a>
					<a href="./emp/empAction?page=${totalPages}">末页 &gt;&gt;</a>
				</s:else>
	
			</p>

		</div>
	</body>
</html>
